package com.vijay.proxy;

import com.vijay.aspect.ServiceAspect;
import com.vijay.service.IUserService;
import com.vijay.service.UserServiceImpl;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.aspectj.annotation.AspectJProxyFactory;
import org.springframework.aop.framework.ProxyFactory;

import java.lang.reflect.Method;
import java.util.Arrays;

public class AspectProxyFactoryMain {

    public static void main(String[] args) {

        aspectProxy();

    }

    public static void aspectProxy() {

        IUserService userService = new UserServiceImpl();
        AspectJProxyFactory ajpf=new AspectJProxyFactory(userService);
        ServiceAspect serviceAspect = new ServiceAspect();
        ajpf.addAspect(serviceAspect);
        IUserService proxy =  ajpf.getProxy();
        proxy.addUser();

    }

}
